<?php
 @header("Content-Type:text/html;charset=utf-8");

 @include_once("conn.php");

 if(!isset($_GET['key'])){
      $obj =array();
      $obj["status"] = false;
      $obj["msg"] = "请传入完整参数";
      $json = json_encode($obj);
      exit($json);
 }

 $key =$_GET["key"];

 $sql = "select id,goodsId,goodsName,goodsPrice,goodsImg from `goodslist_copy` where goodsName like '%${key}%'";

 $result = mysqli_query($conn,$sql);

 $obj = array();
 if($result){
     $list = array();
     while($item = mysqli_fetch_assoc($result)){
        array_push($list,$item);
    }
     $obj["status"] = true;
     $obj["msg"] = "OK";
     $obj["list"] = $list;
 }else{
    $obj["status"]=false;
    $obj["msg"] = "sql语句有误";
    $obj["sql"] = $sql;
 }
 echo json_encode($obj);
?>